from apps.cus_service.models import Cus_Service
from op_drf.serializers import CustomModelSerializer, BaseSerializer
from rest_framework import serializers
from datetime import datetime
from loguru import logger

class WriteServiceSerializer(CustomModelSerializer):
    app_date = serializers.DateField(format="%Y-%m-%d",default=datetime.now())
    # OrderNum = serializers.CharField(required=True)

    def create(self, validated_data):
        # 增加数据的验证
        logger.debug("请求携带的数据： %s" % validated_data)
        instance = super().create(validated_data)
        return instance

    class Meta:
        model = Cus_Service
        fields = "__all__"


'''
读取客服列表
'''
class ReadServiceSerializer(BaseSerializer):
    # OrderStatus_name = serializers.SerializerMethodField(read_only=True)
    # rad_name = serializers.SerializerMethodField(read_only=True)

    # def get_rad_name(self, obj):
    #     if obj.rad:
    #         return obj.rad.name if obj.rad else ""

    class Meta:
        model = Cus_Service
        fields = "__all__"